<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" href="../../css/animate.css">
		<link rel="stylesheet" href="../../iconfont/iconfont.css">
		<link rel="stylesheet" href="../../css/mescroll.css">
		<link rel="stylesheet" href="../../css/gloab.css">
		<title>广告详情</title>
	</head>
	<body>
		<div id="app">
			<div id="public-header">
				<div id="statusbar"></div>
				<header class="public-header">
					<div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
					<div class="public-header-title">广告详情</div>
				</header>
			</div>
			<div style="width:100%;padding-bottom:100px;">
				<div>
					<div class="product-category-list">
						<div class="product-category-list-son" style="box-shadow:none;">
							<div class="product-category-list-header flex wrap">
								<div class="product-category-list-header-lf" style="height:1.1rem;">
									<img :src="apiUrl1+user.avatar" alt="" v-if="user.avatar">
									<img src="../../image/public/touxiang.png" alt="" v-else>
									<label class="product-category-list-header-label">{{user.user_type}}</label>
								</div>
								<div class="product-category-list-header-rt">
									<div class="product-category-list-header-name flex wrap">
										<div class="product-category-list-header-name-lf" style="width:80%;overflow:hidden;height:0.45rem;">{{user.nickname}}</div>
									</div>
									<div class="product-category-list-header-name flex">
										<div class="guanggao-details-head-rt flex wrap">
											<div class="guanggao-details-head-rt-son">曝光次数：<span>{{info.view_count}}</span></div>
											<div class="guanggao-details-head-rt-son">微信号：<span>{{user.wechat}}</span></div>
											<div class="guanggao-details-head-rt-son">发布时间：<span>{{info.update_time_str}}</span></div>
											<div class="guanggao-details-head-rt-son">广告ID：<span>{{info.id}}</span></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="guanggao-details-content">
						<div class="guanggao-details-content-text" v-html="info.content"></div>
						<div class="guanggao-details-content-imgs flex wrap" v-if="info.imgs&&info.imgs.length>0">
							<div class="guanggao-details-content-img" v-for="(items,index) in info.imgs">
								<img @click="seeImg(info,index)" :src="apiUrl1+items" alt="">
							</div>
						</div>
						<p class="auto">注：微信二维码请保存到相册再微信扫码<br>[联系我请备注<span style="color:#ff4747;">趣引流</span>看到的]</p>
					</div>
				</div>
				<!-- <div class="guanggao-details-page flex">
					<div class="guanggao-details-page-son F1" @click="dec">
						<img src="../../image/personal/guanggao_lf.png" alt="">
						<span>上一个</span>
					</div>
					<div class="guanggao-details-page-son F1" @click="Inc">
						<img src="../../image/personal/guanggao_rt.png" alt="">
						<span>下一个</span>
					</div>
				</div> -->
				<div class="guanggao-details-share flex wrap auto" style="margin-top:0.46rem;">
					<div class="guanggao-details-share-lf F2"></div>
					<div class="guanggao-details-share-text F1">分享至</div>
					<div class="guanggao-details-share-lf F2"></div>
				</div>
				<div class="guanggao-details-page auto" style="text-align:center;margin-top:0.2rem;padding-bottom:0.5rem;font-size:0.2rem;">
					<div class="guanggao-details-page-son" style="display:inline-block;margin-right:0.3rem;color:#404040;" @click="shares">
						<img src="../../image/personal/icon1.png" alt="">
						<span>微信</span>
					</div>
					<div class="guanggao-details-page-son" style="display:inline-block;color:#404040;" @click="share">
						<img src="../../image/personal/icon2.png" alt="">
						<span>朋友圈</span>
					</div>
				</div>
				<div class="lingbao-details auto">
					<div class="lingbao-details-head flex">
						<div class="lingbao-details-head-lf F2" style="text-align:right;"><span></span></div>
						<div class="lingbao-details-head-ct F1">领包详情</div>
						<div class="lingbao-details-head-lf F2" style="text-align:left;"><span></span></div>
					</div>
					<div style="color:#000;">福利已抢 <font style="color:#f00;" v-if="list.total">{{list.total}}</font>/{{list.num}}</div>
					<div class="lingbao-details-list">
						<div class="lingbao-details-son flex" v-for="(item,index) in list.list" :style="(list.length-1)==index?'border:none':''">
							<div class="lingbao-details-son-lf">
								<img style="float:left;" v-if="item.user.avatar" :src="apiUrl1+item.user.avatar" alt="">
								<img style="float:left;" src="../../image/public/touxiang.png" alt="" v-else>
							</div>
							<span style="width:80%;overflow:hidden;float:left;">{{item.user.nickname}}</span>
							<div class="lingbao-details-son-rt F1" style="float:left;">￥{{item.money}}</div>
						</div>
					</div>
				</div>
			</div>
			<div v-if="receives">
				<div class="lingbao-details-footer" style="display:block;background:#999;" @click="javascript:api.openWin({name: 'dating',reload:true,url:'./dating.html',allowEdit:true});">您已抢过，更多福利</div>
			</div>
			<div v-else>
				<div class="lingbao-details-footer" style="display:none;">立即领取</div>
				<div class="lingbao-details-footer" style="background-color:#999;color:#fff;" v-show="showCode">请阅读<font style="color:#f00;">{{time}}</font>秒</div>
				<div class="lingbao-details-footer" id="lingqu" style="background-color:#f00;color:#fff" v-show="!showCode" @click="tanchuan">领取红包</div>
			</div>
			<div class="lingbao-details-modify" id="tanchuang" style="display:none;">
				<div class="lingbao-details-modify-close"><img src="../../image/close.png" alt="" @click="del"></div>
				<div class="lingbao-details-modify-center">
					<div class="lingbao-details-modify-headimg" v-if="info&&info.length>0">
						<img :src="info[0].avatar" alt="" v-if="info[0].avatar">
						<img src="../../image/public/touxiang.png" alt="" v-else>
					</div>
					<div class="lingbao-details-modify-text">给你发了一个红包</div>
					<div class="lingbao-details-modify-btn" @click="receive()">立即领取</div>
				</div>
			</div>
		</div>
		<div class="public-progress" style="z-index:9;">
			<img src="../../icon/icon150x150.png" alt="" class="animated infinite flash" style="width:200px;height:200px;display:block;margin:200px auto;">
		</div>
	</body>
	<script src="../../script/api.js"></script>
	<script src="../../script/jquery.js"></script>
	<script src="../../script/mescroll.js"></script>
	<script src="../../script/vue.js"></script>
	<script src="../../script/app.js"></script>
	<script src="../../script/jsencrypt.js"></script>
	<script src="../../script/fastclick.js"></script>

	<script>
		var vm;
		var mescroll;
		var mySwiper;
		apiready = function() {
			api.removeLaunchView();
			setBar("statusbar");
			setFont(750);
			startVue();
			timeOut();
			$(".public-progress").fadeOut(1000);
			setTimeout(function() {
				$(".public-progress").css({
					"display": "none"
				});
			}, 1000);
		}

		function startVue() {
			vm = new Vue({
				el: "#app",
				data: {
					list: [],
					info: [],
					time: 10,
					showCode: true,
					id: '',
					page: 0,
					receives: false,
					num: '',
					nums: '',
					numss: '',
					canvate: false,
					user: ''
				},
				created: function() {
					this.getAdInfo();
					this.getList();
				},
				methods: {
					//获取分享赠送积分
					getIntegral: function() {
						api.ajax({
							url: apiUrl + 'api/home/getIntegral',
							method: 'post',
							data: {
								values: {
									uid: post_en($api.getStorage('uid')),
								},
							}
						}, function(ret, err) {
							if (ret.status) {
								alert(ret.msg);
							} else {
								alert(ret.msg);
							}
						});
					},
					//分享到好友
					shares: function() {
						var wxPlus = api.require('wxPlus');
						wxPlus.isInstalled(function(ret, err) {
							if (ret.installed) {
								var wxPlus = api.require('wxPlus');
								wxPlus.shareWebpage({
									apiKey: '',
									scene: 'session',
									title: '最新项目',
									description: '本条信息由趣引流台推送，您也想自动引流，自动推广就下载吧。',
									thumb: 'widget://icon/logo.jpg',
									contentUrl: apiUrl + "/index.php/index/index/user/user.html?ids=" + JSON.stringify(vm.info[0]['ad_id']),
								}, function(ret, err) {
									if (ret.status) {
										vm.getIntegral();
									} else {
										alert(err.code);
									}
								});
							} else {
								alert('当前设备未安装微信客户端');
							}
						});
					},
					//分享朋友圈
					share: function() {
						var wxPlus = api.require('wxPlus');
						wxPlus.isInstalled(function(ret, err) {
							if (ret.installed) {
								var wxPlus = api.require('wxPlus');
								wxPlus.shareWebpage({
									apiKey: '',
									scene: 'timeline',
									title: '最新项目',
									description: '本条信息由趣引流台推送，您也想自动引流，自动推广就下载吧。',
									thumb: 'widget://icon/logo.jpg',
									contentUrl: apiUrl + "/index.php/index/index/user/user.html?ids=" + JSON.stringify(vm.info[0]['ad_id']),
								}, function(ret, err) {
									if (ret.status) {
										vm.getIntegral();
									} else {
										alert(err.code);
									}
								});
							} else {
								alert('当前设备未安装微信客户端');
							}
						});
					},
					linqu: function() {
						console.log("领取")
						console.log(vm.info.id);
						api.ajax({
							url: apiUrl + 'api/user/getRedpack',
							method: 'post',
							data: {
								values: {
									token: $api.getStorage('token'),
									aid: vm.info.id,
								},
							}
						}, function(ret, err) {
							console.log(JSON.stringify(ret))
							if (ret.code == 1) {} else {
								vm.receives = true;
							}
						});
					},
					linqus: function() {
						vm.time = 10;
						var ids = vm.info['advertising_id'];
						api.ajax({
							url: apiUrl + 'api/redenvelope/linqu',
							method: 'post',
							data: {
								values: {
									uid: post_en($api.getStorage('uid')),
									advertising_id: post_en(ids),
								},
							}
						}, function(ret, err) {
							if (ret.status) {
								vm.receives = ret.data['id'];
								vm.nums = ret.data['nums'];
								vm.num = ret.data['num'];
							} else {
								vm.receives = ret.data['id'];
								vm.nums = ret.data['nums'];
								vm.num = ret.data['num'];
								timeOut();
							}
						});
					},
					seeImg: function(item, index) {
						var array = [];
						for (var i = 0; i < item.image.length; i++) {
							array.push(apiUrl + item.image[i]);
						}
						var photoBrowser = api.require('photoBrowser');
						photoBrowser.open({
							images: array,
							placeholderImg: 'widget://res/img/apicloud.png',
							bgColor: '#000'
						}, function(ret, err) {
							if(ret.eventType == 'longPress'){ save_img(array); }
							if (ret.eventType == 'click') {
								var photoBrowser = api.require('photoBrowser');
								photoBrowser.close();
							}
						});
						photoBrowser.setIndex({
							index: index
						});
					},
					//领包详情
					getList: function() {
						api.ajax({
							url: apiUrl + '/api/user/redpackLog',
							method: 'post',
							data: {
								values: {
									token: $api.getStorage('token'),
									aid: api.pageParam['id']
								},
							}
						}, function(ret, err) {
							console.log(JSON.stringify(ret.data))
							if (ret.code == 1) {
								vm.list = ret.data;
								if (vm.list == null) {
									vm.list = 0;
								}
							} else {
								vm.list = ret.data;
								if (vm.list == null) {
									vm.list = 0;
								}
							}
						});

					},
					//领取红包
					receive: function() {
						if (vm.canvate) {
							return
						};
						vm.canvate = true;
						api.ajax({
							url: apiUrl + '/api/user/getRedpack',
							method: 'post',
							data: {
								values: {
									token: $api.getStorage('token'),
									aid: vm.info.id,
								},
							}
						}, function(ret, err) {
							console.log(JSON.stringify(ret))
							setTimeout(function() {
								vm.canvate = false;
							}, 1000)
							if (ret.code == 1) {
								api.openWin({
									name: 'hongbao_details',
									reload: true,
									url: './hongbao_details.html',
									pageParam: {
										id: vm.id,
										money: ret.data
									}
								});
								location.reload();
							} else {
								api.toast({
									msg: ret.msg,
									duration: 2000,
									location: 'middle'
								});
							}
						});
					},
					//关闭红包提示框
					del: function() {
						$('#tanchuang').css({
							'display': 'none'
						});
					},
					//领取红包提示框
					tanchuan: function() {
						$('#tanchuang').css({
							'display': 'block'
						});
					},
					dec: function() { //上一个
						if (this.page == 0) {
							api.toast({
								msg: '已经到顶了',
								duration: 2000,
								location: 'middle'
							});
							return;
						} else {
							this.page--;
							api.ajax({
								url: apiUrl + 'api/Advertisement/fenyes',
								method: 'post',
								data: {
									values: {
										page: this.page,
										showpage: 1,
									},
								}
							}, function(ret, err) {
								if (ret.status) {
									vm.info = ret.data;
									vm.id = ret.data[0].advertising_id;
									vm.linqus();
								} else {
									vm.info = ret.data;
								}
							});
						}
					},
					Inc: function() { //下一个
						if (vm.numss <= vm.page + 1) {
							api.toast({
								msg: '已是最后一条数据了',
								duration: 2000,
								location: 'middle'
							});
							return;
						} else {
							this.page++;
							api.ajax({
								url: apiUrl + 'api/Advertisement/fenyes',
								method: 'post',
								data: {
									values: {
										page: this.page,
										showpage: 1,
									},
								}
							}, function(ret, err) {
								if (ret.status) {
									vm.id = ret.data[0].advertising_id;
									vm.info = ret.data;
									vm.linqus();
								} else {
									api.toast({
										msg: ret.msg,
										duration: 2000,
										location: 'middle'
									});
									vm.info = ret.data;
								}
							});
						}
					},
					getAdInfo: function() {
						var self = this;
						var token = $api.getStorage('token');
						var id = api.pageParam['id'];
						api.ajax({
							url: apiUrl + '/api/index/adDetail',
							method: 'post',
							data: {
								values: {
									id: id,
								},
							}
						}, function(ret, err) {
							if (ret.code == 1) {
								vm.info = ret.data;
								vm.user = ret.data.user;
								console.log(JSON.stringify(ret))
								vm.id = ret.data.id;
								/* vm.numss = ret.nums; */
							} else {
								vm.info = ret.data;
							}
						});
					},
				}
			})
		}

		function timeOut() {
			setTimeout(function() {
				vm.time--;

				if (vm.time <= 0) {
					vm.showCode = false;
					vm.time = 10;
					return;
				}
				timeOut();
			}, 1000);
		}
	</script>
</html>
